package com.cuit.qx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cuit.qx.bean.AddWeatherStation;
import com.cuit.qx.dao.AddWeatherStationMapper;
import com.cuit.qx.service.AddWeatherStationService;

import com.cuit.qx.utils.WebSocket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddWeatherStationServiceImpl  extends ServiceImpl<AddWeatherStationMapper, AddWeatherStation> implements AddWeatherStationService {

    @Autowired
    AddWeatherStationMapper mapper;

    @Override
    public List<AddWeatherStation> getAllAddWeatherStation() {
        QueryWrapper<AddWeatherStation> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("is_sure","0");
        List<AddWeatherStation> addStations = mapper.selectList(queryWrapper);
        return addStations;
    }

    @Override
    public int updateAddIsSure(String id) {
        int num = mapper.updateAddIsSure(id);
        if (num > 0) {
            WebSocket webSocket = new WebSocket();
            webSocket.sendAllMessage(null);
        }
        return num;
    }
}
